package com.lineage.server.datatables.lock;

import com.lineage.server.datatables.sql.CharacterC1Table;
import com.lineage.server.datatables.storage.CharacterC1Storage;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.templates.L1User_Power;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class CharacterC1Reading {
  private final Lock _lock = new ReentrantLock(true);
  
  private final CharacterC1Storage _storage = (CharacterC1Storage)new CharacterC1Table();
  
  private static CharacterC1Reading _instance;
  
  public static CharacterC1Reading get() {
    if (_instance == null)
      _instance = new CharacterC1Reading(); 
    return _instance;
  }
  
  public void load() {
    this._lock.lock();
    try {
      this._storage.load();
    } finally {
      this._lock.unlock();
    } 
  }
  
  public L1User_Power get(int objectId) {
    L1User_Power tmp;
    this._lock.lock();
    try {
      tmp = this._storage.get(objectId);
    } finally {
      this._lock.unlock();
    } 
    return tmp;
  }
  
  public void storeCharacterC1(L1PcInstance pc) {
    this._lock.lock();
    try {
      this._storage.storeCharacterC1(pc);
    } finally {
      this._lock.unlock();
    } 
  }
  
  public void updateCharacterC1(int object_id, int c1_type, String note) {
    this._lock.lock();
    try {
      this._storage.updateCharacterC1(object_id, c1_type, note);
    } finally {
      this._lock.unlock();
    } 
  }
}
